<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <router-view></router-view>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>
    <script>

        //什么是路由参数?
        //路由参数就是在指定路由规则的时候，在路由路径中使用:进行占位的参数

        //?表示参数可传可不传！

        let Detail = {
            template: "<div>这是详情页 用户传入的id为{{$route.params.id}}</div>",
            created(){
                console.log(this.$route)
            }
        }


        //这个router对象，也会被存到vue实例中 可以通过this.$router访问
        let router = new VueRouter({
            routes: [
                {
                    //   真实url  /detail/123
                    //   真实url  /detail/18/zcm
                    path: "/detail/:id/:name/:gender",
                    component: Detail
                }
            ]
        })

        var vm = new Vue({
            el: "#app",
            data: {
            },
            router
        })
    </script>
</body>

</html>